using System.Collections.Generic;
using System.IO;

namespace CheckoutCodeKata
{
    public class ControllerFactory
    {
        private readonly TextWriter _textWriter;
        private readonly Dictionary<string, int> _prices;
        private readonly List<SpecialPriceRule> _specialPricesRules;

        public ControllerFactory(TextWriter textWriter, Dictionary<string, int> prices, List<SpecialPriceRule> specialPricesRules)
        {
            _textWriter = textWriter;
            _prices = prices;
            _specialPricesRules = specialPricesRules;
        }

        public Controller Create()
        {
            var display = new Display(_textWriter);
            var priceList = new PriceList(_prices);
            var counter = new Counter(display);
            var quantityPrices = new QuantityPrice(priceList, counter);
            var specialPrices = new SpecialPricesRule(quantityPrices, counter, _specialPricesRules);
            var items = new Items(specialPrices);
            return new Controller(counter, items);
        }
    }
}